package com.chookss.video.recommend;


import android.annotation.SuppressLint;
import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.fragment.app.Fragment;

import com.chookss.R;
import com.chookss.Urls;
import com.chookss.tools.NavigationTools;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.Unbinder;

import static android.view.View.OVER_SCROLL_NEVER;

@SuppressLint("ValidFragment")
public class VideoDetailWebFragment extends Fragment {

    public Context mContext;
    Unbinder unbinder;
    @BindView(R.id.webView)
    MyWebView webView;
    private String courseCode,url;

    public VideoDetailWebFragment(String courseCode) {
        this.courseCode = courseCode;
    }

    public VideoDetailWebFragment() {

    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mContext = getActivity();
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_vedio_detail_web, container, false);
        unbinder = ButterKnife.bind(this, view);
        init();
        return view;
    }

    @Override
    public void onViewCreated(View view, Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
    }

    private void init() {
        webView.setVerticalScrollBarEnabled(false);
        webView.setHorizontalScrollBarEnabled(false);
        webView.setOverScrollMode(OVER_SCROLL_NEVER);
         url= NavigationTools.getAllUrl(mContext,Urls.courseDetail)+"&courseCode="+courseCode;
        webView.loadUrl(url);
    }
  public void chageUrl(String courseCode){
      this.courseCode = courseCode;
      url= NavigationTools.getAllUrl(mContext,Urls.courseDetail)+"&courseCode="+courseCode;
      webView.loadUrl(url);
  }
    @Override
    public void onDestroy() {
        super.onDestroy();
        if(unbinder!=null){
            unbinder.unbind();
        };
    }
}
